<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.util.List" %>
<%@ page import="com.appspot.androidquote.webapp.Entities.MessageEntity" %>
<%@ page import="com.appspot.androidquote.webapp.dao.MessageDao" %>

<!DOCTYPE html>


<%@page import="java.util.ArrayList"%>

<html>
  <head>
    <title>Messages</title>
    <link rel="stylesheet" type="text/css" href="css/main.css"/>
      <meta charset="utf-8"> 
  </head>
  <body>
<%
MessageDao dao = MessageDao.INSTANCE;

List<MessageEntity> messages = new ArrayList<MessageEntity>();
messages = dao.getAllMessages();
    
%>
  <div style="width: 100%;">
    <div class="line"></div>
    <div class="topLine">
      <div style="float: left;" class="headline">Messages</div>
    </div>
  </div>

<div style="clear: both;"/>  
You have a total number of <%= messages.size() %>  Messages.

<table>
  <tr>
      <th>Category</th>
      <th>Message</th>
      <th>Author</th>
      <th>Delete</th>
    </tr>

<% for (MessageEntity message : messages) {%>
<tr> 
<td>
<%=message.getCategory()%>
</td>
<td>
<%=message.getMessage()%>
</td>
<td>
<%=message.getAuthor()%>
</td>
<td>
<a class="done" href="/delete?id=<%=message.getId()%>" >Delete</a>
</td>
</tr> 
<%}
%>
</table>


<hr />

<div class="main">

<div class="headline">New message</div>

<form action="/new" method="post" accept-charset="utf-8">
  <table>
    <tr>
      <td><label for="category">Category</label></td>
      <td><input type="text" name="category" id="category" size="65"/></td>
    </tr>
    <tr>
      <td><label for="author">Author</label></td>
      <td><input type="text" name="author" id="author" size="65" /></td>
    <tr>
    <tr>
      <td><label for="message">Message</label></td>
      <td><textarea rows="4" cols="50" name="message" id="message"></textarea></td>
    </tr>
  <tr>
      <td colspan="2" align="right"><input type="submit" value="Create"/></td>
    </tr>
  </table>
</form>

</div>
</body>
</html>